home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / ffit162.zoo / ffit.doc next >
Text File  |  1992-12-07  |  18KB  |  427 lines

  1.  
  2.  
  3.               FFIT ver 1.62, December 1992 by Kai Risku
  4.               =========================================
  5.  
  6. This program was made to help you copy files to disks, without having to
  7. think about how to group the files so they will take up the least number
  8. of disks. This problem is often referred to as the 'The Knapsack
  9. Problem'. FFIT checks the size of the disks you are going to copy to and
  10. then combines the files so they will fill the disks optimally. After
  11. this, the program will copy the files to the disks prompting you for
  12. each disk.
  13.  
  14. Several options are available to modify the way FFIT works. You can
  15. specify alphabetical sorting, no grouping (sequential copying), wanted
  16. volume size, how much space you want to leave free on the disks, only
  17. use files with archive bit set, test mode (just print the filenames, do
  18. not copy), and much more. 4DOS/NDOS file descriptions are also handled.
  19.  
  20. Please note that the sorting may take a while, so be patient when using
  21. this program. Also note that since this program copies everything to the
  22. root of the target disks, there is a limit to how many files can be
  23. placed there. As an example can be said that on a 1.44 Mb diskette you
  24. can have 224 files in the root directory. This program will not check
  25. the maximum number of files that may be placed in the root directory.
  26. Therefore you might get an 'Error copying file' if the program tries to
  27. copy too many files to one disk.
  28.  
  29.  
  30. Ok, how do I use this wonderful program..
  31. =========================================
  32.  
  33. Syntax:     FFIT [options] [filespecs..] [@listfile] target:
  34.  
  35. The target drive must be a removable medium. Arguments may appear in any
  36. order. An argument starting with '-' or '/' is interpreted as an option.
  37. The filespec can be one or more directories or filenames with or without
  38. wildcards. You can also put all desired directories or filenames (each
  39. on a separate line) in an ordinary textfile and specify '@filename' as
  40. the filespec.
  41.  
  42. FFIT is fully compatible with 4DOS/NDOS file descriptions.
  43. When using FFIT all descriptions will be dealt with automagically.
  44.  
  45. The following options can be used:
  46.  
  47.  
  48. -a          add
  49. ===============
  50.  
  51.     Use the space available on the disk. If this option is NOT
  52.     specified, the program will use the whole capacity of the disk, and
  53.     thus require totally empty disks (non-empty disks will be erased
  54.     after prompting the user for permission).
  55.  
  56.     You MUST use this option if you want to to add files to a disk where
  57.     there are already some files! If the -a option is given, the program
  58.     cannot say how many disks will be required, as this depends on the
  59.     space available. Without this option the program will say how many
  60.     disks is needed before the copying begins.
  61.  
  62.  
  63. -b          sort big files first
  64. ================================
  65.  
  66.     If you specify this option all files will be sorted according to
  67.     size, biggest first. By using this option, the disks can get a
  68.     little bit better filled. If you are fitting to many disks, the
  69.     difference between using this option or not, usually means that the
  70.     second last disk might not be perfectly filled.
  71.  
  72.     The drawback of using this option is that because all big files are
  73.     sorted first, the last disks are filled with lots of small files. Do
  74.     not use this option if you want your files evenly spread among the
  75.     disks.
  76.  
  77.  
  78. -c          archive bits
  79. ========================
  80.  
  81.     Copy only files with the archive bit set. The archive bit will be
  82.     reset after the file has been copied. This could be useful if you
  83.     have lots of files but only a limited number of disks and you are
  84.     not able to copy all files at once. Set the archive bit on all files
  85.     and then use this option. At a later time you can restart FFIT and
  86.     copy the files that has not already been copied.
  87.  
  88.  
  89. -d n        start with disk number n
  90. ====================================
  91.  
  92.     This is useful if you have aborted the program and wish to continue
  93.     from a given disk. The space between d and the number can be left
  94.     out. This option cannot be used together with option -a.
  95.  
  96.  
  97. -f          force
  98. =================
  99.  
  100.     No prompting for permission will be done. Normally the program will
  101.     ask when you are about to erase a disk, overwrite files or if there
  102.     are read-only files that are about to be erased, but with this
  103.     option given no questions will be asked. Could be dangerous!
  104.  
  105.  
  106. -m          move
  107. ================
  108.  
  109.     After a disk has been successfully copied, the source files will be
  110.     deleted. You will be asked to confirm every read-only file unless
  111.     option -f is given.
  112.  
  113.  
  114. -n          no grouping
  115. =======================
  116.  
  117.     The files will be copied in the same order as specified, one at a
  118.     time and requesting a new disk when the next file won't fit.
  119.  
  120.  
  121. -q          quiet
  122. =================
  123.  
  124.     Just a silly little option to generate absolutely quiet beeps.
  125.  
  126.  
  127. -s          sort alphabetical
  128. =============================
  129.  
  130.     The files will be copied in alphabetical order to the disks.
  131.     Normally this will just result in a nicer directory listing, but if
  132.     used together with the option -n, all filenames will be globally
  133.     sorted.
  134.  
  135.  
  136. -t [size]   test mode
  137. =====================
  138.  
  139.     Do not write or delete anything, just simulate and print all texts
  140.     as they would otherwise appear. This is very useful if you want to
  141.     know in advance which files will go on which disks.
  142.  
  143.     You may also specify an optional argument. This argument must then
  144.     be one of the following: 160, 180, 320, 360, 720, 120, 144. Normally
  145.     FFIT will always examine the target disk to see what capacity it is,
  146.     but by using this argument you can set a disksize to use. In this
  147.     case you do not need to have a disk in the target drive, which could
  148.     come in handy when you just want to test. In this case the target
  149.     drive can be omitted from the command line.
  150.  
  151.  
  152. -u          uppercase
  153. =====================
  154.  
  155.     Print all filenames in UPPERCASE. This has only aesthetical value
  156.     and will make very loud filenames.
  157.  
  158.  
  159. -v size     volume size
  160. =======================
  161.  
  162.     Fit files to the specified volume size. The numeric argument can be
  163.     suffixed with 'k' or 'M', meaning kilo (times 1024) or Mega (times
  164.     1024*1024). You can also use a decimal point, as in 1.2M which then
  165.     means 1.2*1024*1024 bytes.
  166.  
  167.     If the specified size is negative, that much free space will be left
  168.     on each disks. The space between v and size can be left out.
  169.  
  170.  
  171. Options can be combined, and several options can also be specified after
  172. the same '-' or '/'. The only exception is that no more options can be
  173. combined after a numeric argument. In that case you must start with a
  174. new '-' or '/'.
  175.  
  176. Example: If you want to give the options add, sort, start with
  177.          disk number 3 and test mode, all the following is legal:
  178.                  -a -s -d3 -t
  179.                  /astd3
  180.                  -as -d 3 -t
  181.         But you cannot use: -asd3t   since you cannot place any
  182.         option characters immediately after the '3'.
  183.  
  184.  
  185. You can specify as many filenames you wish, and they may contain
  186. wildcards. If you want to copy a whole directory, you can simply
  187. specify the name of the directory. Files that are larger than the
  188. target disk, as well as non-existent files, will be skipped.
  189.  
  190.  
  191. Run-time options and what is happening
  192. ======================================
  193.  
  194. When FFIT is started, all given filenames must first be processed. This
  195. involves getting the name, size and eventuelly a 4DOS/NDOS description.
  196. While this is happening, an indicator will indicate (what else should an
  197. indicator do?) that the program is doing some work. Depending on the
  198. number of files and the speed of the computer, this can take some time.
  199.  
  200. After this is done, you will se how the fitting proceeds. Starting with
  201. disk number one, the program will display a number of bytes which should
  202. be rapidly decreasing. This indicates how many bytes from the target
  203. size the best combination so far yields.
  204.  
  205. Normally the number decreases to zero in a very short moment and the
  206. program proceeds to the next disk. FFIT will systematically examine
  207. every possible combination before accepting the best result it can find.
  208.  
  209. If there are many files, the number of combinations are numerous and
  210. you may think the program is not doing anything because the number is
  211. not decreasing. Don't panic! There are just an enormous number of
  212. combinations that have not been tested yet. Relax and let the program
  213. do the crunching. If you run out of patience you may press ESC and
  214. FFIT will respond with the following prompt:
  215.  
  216.             [Halted!]  C)ontinue, A)ccept fit or Q)uit?
  217.  
  218. Now you may q)uit the program, a)ccept the best combination so far
  219. or c)ontinue crunching those combinations. The choice is yours.
  220.  
  221. When FFIT has determined how the files are to be grouped, it will ask
  222. for the first disk (unless you have specified a certain starting disk
  223. using the -d option) and at this point you might press ? or H for help.
  224. FFIT will display:
  225.  
  226.         Your possible keystrokes are:
  227.             ENTER or SPACE  start working with disk
  228.             S               skip this disk
  229.             ESC or Q        quit program
  230.             D or ^Z         shell to dos
  231.             ? or H          this help
  232.  
  233. Your possibilities are quite self-explanatory. Note that you cannot
  234. skip a disk if you have given the -a option. When you go on with ENTER
  235. or SPACE the files will be copied to the disk. Unless the option -a is
  236. given, the disk must be totally empty. If FFIT detects data on the
  237. disk and option -a is NOT given, the program will ask for permission
  238. to delete the whole disk. At this point you may shell to dos and
  239. examine the disk, try with another disk, quit the program or give FFIT
  240. permission to delete the whole disk.
  241.  
  242.  
  243. Some useful examples
  244. ====================
  245.  
  246. FFIT -t \misc\texts \temp\*.doc b:
  247.  
  248.         This test-fits all files in the directory '\misc\texts' and all
  249.         files matching '\temp\*.doc' to the drive b:. Nothing will be
  250.         copied, but the program will tell you how many disks you are
  251.         going to need as well as which files are put on which disks.
  252.  
  253. FFIT a: /fms .
  254.  
  255.         All files in the current directory will be fitted to a:. The
  256.         files will be copied in alphabetical order (-s), and after
  257.         each disk has been successfully copied, the source files will
  258.         be deleted (-m) without asking for permission even if some
  259.         files are read-only (-f).
  260.  
  261.         NOTE! Because the option -a was NOT specified, the target
  262.         disks must be empty, and FFIT will erase the target disk
  263.         without asking since the force-option (-f) was given. Omit the
  264.         -f and FFIT will ask for permission to delete the target disk.
  265.  
  266. FFIT -a -n -u c:\foo\*.arj b:
  267.  
  268.         The matching files are added (-a) to the disk(s) in drive b:.
  269.         Files already existing on the disks will be left undisturbed!
  270.         Because of this, FFIT cannot know in advance how many disks
  271.         will be needed to copy all files. You can use the test option
  272.         (-t) to achieve this. Files are copied in the same order as
  273.         specified (-n) and all filenames are printed in uppercase (-u).
  274.  
  275. FFIT -cv720k c:\backups\*.zip a:
  276.  
  277.         The matching files whose archive bits are set (-c) will be fitted
  278.         to a: copying no more than 720 Kb to each disk (-v 720k).
  279.         After each file has been copied, its archive bit will be reset.
  280.  
  281. FFIT -a -v -10000 @mylist.txt a:
  282.  
  283.         The files mentioned in the textfile 'mylist.txt' will be added
  284.         to the disk(s) in drive a: leaving at least 10000 bytes of
  285.         free space on each disk.
  286.  
  287. FFIT *.zip *.arj -bt144
  288.  
  289.         All matching files will be fitted using the 'biggest first'
  290.         sorting. The target is assumed to be a totally empty 1.44 Meg
  291.         disk (-t144) and we are of course only testing to see how the
  292.         files would be copied.
  293.  
  294. FFIT -d5 *.gif b:
  295.  
  296.         The first four disks will be skipped and copying will begin
  297.         with disk number five. This can be used to continue where
  298.         you left off if you had to abort FFIT.
  299.  
  300.  
  301. As you may have noticed, there are many options and they can be freely
  302. combined to obtain the desired result. If you think you need yet another
  303. option which I haven't so far implemented, please tell me about it!
  304.  
  305.  
  306. Known limitations
  307. =================
  308.  
  309. Solving a knapsack problem is not such an easy task. Even if
  310. considerable effort (not to mention all those late nights) has been
  311. spent to make this program work, some things are just very hard to
  312. implement. Therefore there are some limitations. Some may go away in
  313. the future, some may not.
  314.  
  315. There is a limitation to how many files can be placed in the root
  316. directory of a disk. This is not checked in any way, so do not be
  317. surprised if FFIT cannot copy any more files to a disk even if there
  318. is space left.
  319.  
  320. At the moment FFIT copies files to the root directory of the disk
  321. only. Copying to a subdirectory means there will be a dynamic number
  322. of sectors used for the directory. The number of sectors used, depends
  323. of the number of files in the subdirectory. At the moment, it just
  324. feels way too complicated to achive a "perfect fit" when having to
  325. compensate for directory clusters also.
  326.  
  327. If you add files to a disk where there is already files having the
  328. same name, you will be asked if to overwrite the file on the disk. In
  329. this situation, the real amount of bytes free left on the disk (after
  330. copying) will not be the same as the value FFIT has calculated.
  331.  
  332. If the target disk have lost clusters, you may find that FFIT will not
  333. be able to copy all files to the disk. The last file copied may be
  334. truncated. Use 'chkdsk /f' to fix the lost clusters on the disk and
  335. then run FFIT again.
  336.  
  337. Perhaps the fitting algorithm could be optimized, but I think it does
  338. the job as good and fast as it might be possible. There are of course
  339. situations when the algorithm may do some unneccessary work, but the
  340. result should pretty near the best possible. An example of a worst case
  341. is if you have many files of equal size, and the size is not a whole
  342. multiple of the space available. All combinations of the files will be
  343. tried, even if they all yield the same amount of 'bytes left'.
  344.  
  345. More causes of grief may exist. If you find any, you will know it. If
  346. you don't, it will probably not bother you. You have been warned!
  347.  
  348. Any good ideas to cure the known (and unknown) limitations can be sent
  349. to the address given at the end of this document. Please report any
  350. bugs or undocumented features found in the program.
  351.  
  352.  
  353. Revision history
  354. ================
  355.  
  356. Version 1.62:   Decreased memory usage at startup and added some more
  357.                 checks for insufficient memory at runtime.
  358.  
  359. Version 1.61:   Fixed bug that caused the program to loop infinitely
  360.                 on zero length files when using option -b. Added an
  361.                 indicator while parsing filenames.
  362.  
  363. Version 1.6:    Added full support for 4DOS/NDOS file comments. Added
  364.                 possibility to specify disksize when using the test
  365.                 option. Added the -q (quiet) option. Added check that
  366.                 target is a removable medium. Added the -b (sort big
  367.                 files first) option which can give a slightly better
  368.                 result. Fixed two bugs in the dos-shell (prompt and
  369.                 current directory restored after shell). Files are now
  370.                 copied to the root of the target (as they should), not
  371.                 to the current directory. Target drive can be specified
  372.                 anywhere on the command line, or omitted if using the
  373.                 predefined disksize test-mode. Some code simplified and
  374.                 optimized. Several other small aesthetical tweaks.
  375.  
  376. Version 1.5:    Fixed bug in erase_whole_disk which failed to erase
  377.                 hidden and system files. Redisplay last question when
  378.                 returning from dos shell. Added option 'd' and
  379.                 possibility to skip disk about to be ffitted.
  380.  
  381. Version 1.4:    Possibility to shell to dos. Listfiles implemented.
  382.                 Added progress indicators while copying files. Added
  383.                 options 'c' and 'v'. Name changed from 'fit' to 'ffit'
  384.                 because there already existed a program named 'fit'.
  385.  
  386. Version 1.3:    Possibility to break (cont, accept or quit) during fit.
  387.                 Fixed 'bytes left'-bug. Added code selfcheck.
  388.  
  389. Version 1.2:    Added add and move option and printing of bytes left on
  390.                 each diskette after copying. Increased stack size,
  391.                 because the program could sometimes crash when the
  392.                 algorithm recursed deep enough.
  393.  
  394. Version 1.1:    Added alphabetical sorting.
  395.  
  396. Version 1.0:    Initial release of program.
  397.  
  398.  
  399.  
  400. #include <std_disclaimer.h>:
  401. ============================
  402.  
  403.                 Copyright (c) 1991, 1992 Kai Risku
  404.  
  405. FFIT is offered to you "AS IS" without any warranty. This software has
  406. been thoroughly tested but no guarantee is given that it will work on
  407. every computer. The copyright owner may not be held liable for any
  408. damages, direct or consequential, which may result from the the use of
  409. this program.
  410.  
  411. This program is freely distributable. You may use the software and
  412. share it with all your friends (and foes) as long as the program is
  413. supplied in its original, unmodified form, which includes this
  414. documentation. This program must not be distributed for profit.
  415.  
  416. If you have any questions, ideas, suggestions for improvements or if
  417. you are interested in the source then feel free to contact me...
  418.  
  419. A nice postcard would be appreciated!
  420.  
  421.  
  422. Snailmail:      Kai Risku         Email (internet):  Kai.Risku@hut.fi
  423.                 Kronvik
  424.                 65410 Sundom
  425.                 Finland
  426.  
  427.